/**
 * Main class that handles connection with the other classes
 * 
 * @author remo.lemma@lu.unisi.ch and patrick.zulian@lu.unisi.ch
 */


package ch.unisi.inf.projects.java.uom;

import ch.unisi.inf.projects.java.uom.elements.ItemClass;
import ch.unisi.inf.projects.java.uom.elements.ItemManager;
import ch.unisi.inf.projects.java.uom.gui.GUI;
import ch.unisi.inf.projects.java.uom.gui.NameController;

public final class UOM {
	
	/**
	 * The main function executed when the program starts
	 * 
	 * @param args array of strings containing the arguments (usually empty)
	 * @throws Exception handles all the exceptions
	 */
	public static void main (final String args[]) throws Exception
	{	
		NameController.instance(); // Avoid conflict with ItemManager listeners
		new GUI();
	}
	
	/**
	 * Makes the necessary work to make the UOM new database correctly working
	 * @throws Exception handles the needed exceptions
	 */
	public static void init () throws Exception
	{
		/* Create Multimedia ItemClass */
		final ItemManager manager = ItemManager.instance();
		final ItemClass multimedia = new ItemClass("MULTIMEDIA");
		manager.elementAddField(multimedia, "STRING_TYPE", null);
		manager.elementAddField(multimedia, "STRING_COMMENT", null);
		manager.elementAddField(multimedia, "STRING_URL", null);
		manager.elementSave(multimedia);
	}
}